﻿using System;

namespace BIStudio.Framework.Cache
{
    public interface ICache
    {
        /// <summary>
        /// 设置缓存值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="hashKey"></param>
        /// <param name="value"></param>
        /// <param name="cacheMinutes"></param>
        /// <returns></returns>
        void Add<T>(string hashKey, T value, int cacheMinutes);

        /// <summary>
        /// 尝试从缓存中获取指定方法的返回值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="hashKey"></param>
        /// <returns></returns>
        T Get<T>(string hashKey);

        /// <summary>
        /// 删除缓存
        /// </summary>
        /// <param name="hashKey"></param>
        void Remove(string hashKey);

        /// <summary>
        /// 清空全部缓存
        /// </summary>
        void Clear(string prefix);

        /// <summary>
        /// 检查缓存状态
        /// </summary>
        /// <param name="hashKey"></param>
        /// <returns></returns>
        bool Contains(string hashKey);
    }
}